#include <ostream>
#include "LinkStack.h"

class Person {
public:
    LinkNode node;
    string name;
    int age;

    Person(const string &name, int age) : name(name), age(age) {}

    friend ostream &operator<<(ostream &os, const Person &person) {
        os << "name: " << person.name << " age: " << person.age;
        return os;
    }
};

int main() {

    LinkStack* stack = new LinkStack();

    Person p1("aaa",18);
    Person p2("bbb",19);
    Person p3("ccc",20);
    Person p4("ddd",21);
    Person p5("eee",22);


    stack->Push_LinkStack((LinkNode*)&p1);
    stack->Push_LinkStack((LinkNode*)&p2);
    stack->Push_LinkStack((LinkNode*)&p3);
    stack->Push_LinkStack((LinkNode*)&p4);
    stack->Push_LinkStack((LinkNode*)&p5);

    while (stack->Size_LinkStack() > 0) {
        //取出栈顶元素
        Person* p = (Person*)stack->Pop_LinkStack();
        cout<<*p<<endl;
    }

    stack->FreeSpace_LinkStack();

    return 0;
}